package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.KdBean;
import com.lwj.liwanjia.impl.KdView;
import com.lwj.liwanjia.model.KdModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/28.
 */

public class KdPresenter {
    private KdView kdView;
    private KdModel kdModel;

    public KdPresenter(KdView kdView) {
        this.kdView = kdView;
        kdModel = new KdModel();
    }

    public void getKdData(String token) {
        if (kdView != null) {
            kdModel.getKdData(token, new Subscriber<KdBean>() {
                @Override
                public void onCompleted() {
                    kdView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    kdView.showError((Exception) e);
                    kdView.hideProgress();
                }

                @Override
                public void onNext(KdBean kdBean) {
                    kdView.getKdData(kdBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    kdView.showProgress();
                }
            });
        }
    }
}
